package jjn.round1;

/**
 * @author Jjn
 * @since 2022-08-06 15:25
 */
public class LeetCode744_FindSmallestLetterGreaterThanTarget {
    
    public char nextGreatestLetter(char[] letters, char target) {
        int length = letters.length;
        int low = 0, high = length - 1;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            char letter = letters[mid];
            if (letter > target) {
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        return letters[low % length];
    }
}
